package com.xnyzc.lhy.mis.util;

import com.xnyzc.lhy.common.constant.CommonConstant;
import org.joda.time.DateTime;

import java.util.Date;

/**
 * @Description: 时间工具类
 * @Author: scootXin
 * @Date: 2019/5/27 11:26
 */
public class PangTimeUtil {

    /**
     * 获取清算时间
     *
     * @return
     */
    public static Date getClearTime() {
        DateTime dateTime = new DateTime();
        dateTime = dateTime.plusDays(CommonConstant.CLEAR_WAIT_TIME);

        return dateTime.toDate();
    }

    /**
     * 获取当月起始和结束时间
     *
     * @return
     */
    public static Date[] getMouthBetweenTime() {
        DateTime dateTime = new DateTime();
        Date first = dateTime.dayOfMonth().withMinimumValue().withMillisOfDay(0).toDate();
        Date last = dateTime.dayOfMonth().withMaximumValue().plusDays(1).withMillisOfDay(0).toDate();

        return new Date[]{first, last};
    }

    /**
     * 获取当周起始和结束时间
     *
     * @return
     */
    public static Date[] getWeekBetweenTime() {
        DateTime dateTime = new DateTime();
        Date first = dateTime.dayOfWeek().withMinimumValue().withMillisOfDay(0).toDate();
        Date last = dateTime.dayOfWeek().withMaximumValue().plusDays(1).withMillisOfDay(0).toDate();

        return new Date[]{first, last};
    }

    /**
     * 获取当天起始结束时间
     *
     * @return
     */
    public static Date[] getDayBetweenTime() {
        DateTime dateTime = new DateTime();
        Date first = dateTime.withMillisOfDay(0).toDate();
        Date last = dateTime.plusDays(1).withMillisOfDay(0).toDate();

        return new Date[]{first, last};
    }
}
